-
Notifications
You must be signed in to change notification settings - Fork 84
Feat: Adds game-specific save location symlink support #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Implements a system to create symbolic links for game save locations, addressing compatibility issues with games that store saves in non-standard locations. Adds a registry to define these workarounds, allowing for automatic creation of symlinks based on the game's app ID. The system supports placeholders for Steam ID and Account ID to accommodate user-specific save paths.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds a new SpecialGameSaveMapping data class and registry, plus a new SteamUtils.public function ensureSaveLocationsForGames(context, steamAppId) that resolves game-specific save mappings, computes Steam-ID placeholders, and creates symlinks from target to source with logging and error handling. Changes
Sequence Diagram(s)sequenceDiagram
participant App as App Flow
participant SteamUtils as SteamUtils
participant Mapping as SpecialGameSaveMapping
participant FS as FileSystem
App->>SteamUtils: ensureSaveLocationsForGames(context, steamAppId)
SteamUtils->>Mapping: lookup mapping by appId
Mapping-->>SteamUtils: mapping (sourceRelativePath, targetRelativePath, pathType)
SteamUtils->>App: resolve user Steam IDs ({64BitSteamID}, {Steam3AccountID})
SteamUtils->>FS: check if source path exists
alt source exists
SteamUtils->>FS: check if target exists and is symlink
alt target missing or is symlink
SteamUtils->>FS: create symlink target -> source
FS-->>SteamUtils: success / failure
else target exists and not symlink
FS-->>SteamUtils: report existing non-symlink
end
else source missing
FS-->>SteamUtils: report missing source
end
SteamUtils-->>App: return / log result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="app/src/main/java/app/gamenative/utils/SteamUtils.kt">
<violation number="1" location="app/src/main/java/app/gamenative/utils/SteamUtils.kt:1238">
P2: Missing `PrefManager` fallback for Steam ID retrieval. Other functions in this file (e.g., `ensureSteamSettings`) check `PrefManager.steamUserSteamId64` and `PrefManager.steamUserAccountId` as fallbacks before defaulting to "0". Without this fallback, symlinks could be created with "0" in the path when the Steam ID is temporarily unavailable from `SteamService`.
(Based on your team's feedback about adding fallbacks when reading optional data.) [FEEDBACK_USED]</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| val accountId = SteamService.userSteamId?.accountID?.toLong() ?: 0L | ||
| val steamId64 = SteamService.userSteamId?.convertToUInt64()?.toString() ?: "0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Missing PrefManager fallback for Steam ID retrieval. Other functions in this file (e.g., ensureSteamSettings) check PrefManager.steamUserSteamId64 and PrefManager.steamUserAccountId as fallbacks before defaulting to "0". Without this fallback, symlinks could be created with "0" in the path when the Steam ID is temporarily unavailable from SteamService.
(Based on your team's feedback about adding fallbacks when reading optional data.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/utils/SteamUtils.kt, line 1238:
<comment>Missing `PrefManager` fallback for Steam ID retrieval. Other functions in this file (e.g., `ensureSteamSettings`) check `PrefManager.steamUserSteamId64` and `PrefManager.steamUserAccountId` as fallbacks before defaulting to "0". Without this fallback, symlinks could be created with "0" in the path when the Steam ID is temporarily unavailable from `SteamService`.
(Based on your team's feedback about adding fallbacks when reading optional data.) </comment>
<file context>
@@ -1209,5 +1221,59 @@ object SteamUtils {
+ val workaround = SaveLocationWorkaround.registry.find { it.appId == steamAppId } ?: return
+
+ try {
+ val accountId = SteamService.userSteamId?.accountID?.toLong() ?: 0L
+ val steamId64 = SteamService.userSteamId?.convertToUInt64()?.toString() ?: "0"
+ val steam3AccountId = accountId.toString()
</file context>
| val accountId = SteamService.userSteamId?.accountID?.toLong() ?: 0L | |
| val steamId64 = SteamService.userSteamId?.convertToUInt64()?.toString() ?: "0" | |
| val accountId = SteamService.userSteamId?.accountID?.toLong() | |
| ?: PrefManager.steamUserAccountId.takeIf { it != 0 }?.toLong() | |
| ?: 0L | |
| val steamId64 = SteamService.userSteamId?.convertToUInt64()?.toString() | |
| ?: PrefManager.steamUserSteamId64.takeIf { it != 0L }?.toString() | |
| ?: "0" |
| * - {64BitSteamID} - Replaced with the user's 64-bit Steam ID | ||
| * - {Steam3AccountID} - Replaced with the user's Steam3 account ID | ||
| */ | ||
| data class SaveLocationWorkaround( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend giving this a more approprate name like "bindedSaveLocation" or something. Workaround always makes it sound hacky :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated see if you agree this name
This is useful when some games will create another directory for saves if the game is not start from steam client.
Implements a system to create symbolic links for game save locations, addressing compatibility issues with games that store saves in non-standard locations.
Adds a registry to define these workarounds, allowing for automatic creation of symlinks based on the game's app ID.
The system supports placeholders for Steam ID and Account ID to accommodate user-specific save paths.
Supported game now:
The First Berserker: Khazan (2680010)
Related steam discussion with this issue:
https://steamcommunity.com/app/2680010/discussions/0/595144651000835275/#c595144799751775858
Summary by cubic
Adds game-specific save location symlink support to fix save path mismatches when games aren’t launched from the Steam client. Automatically applies per app ID; initial support for The First Berserker: Khazan (2680010).
Written for commit 5ff6fee. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.